/*
+--------------------------------------------------------------------------
|   Mblog [#RELEASE_VERSION#]
|   ========================================
|   Copyright (c) 2014, 2015 mtons. All Rights Reserved
|   http://www.mtons.com
|
+---------------------------------------------------------------------------
*/
package mblog.core.data;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author mark
 *
 */
@Data
public class AccountProfile implements Serializable {
    private static final long serialVersionUID = 1748764917028425871L;
    private long id;
    private String username;
    private String avatar;
    private String name;
    private String email;
    private String mobile;
    /**
     *
     */
    private String address;//用户住处 地址
    private String province;// VARCHAR(20) NULL COMMENT '省份信息';
    private String city;// VARCHAR(20) NULL COMMENT '市信息';
    private String location;// VARCHAR(20) NULL COMMENT '县或区信息';
    /**
     *
     */

    private Date lastLogin;
    private int status;
    private boolean guest;

    private int roleId;
    private int activeEmail;

    private List<AuthMenu> authMenus;

    private BadgesCount badgesCount;

    public AccountProfile(long id, String username) {
        this.id = id;
        this.username = username;
    }

    /**
     * 我也是拼了。。。冒泡排序法居然还能默写出来
     *
     * @param authMenus
     */
    public void setAuthMenus(List<AuthMenu> authMenus) {
        for (int i = 0; i < authMenus.size(); i++) {
            for (int j = authMenus.size() - 1; j > 0; j--) {
                if (authMenus.get(i).getSort() > authMenus.get(j).getSort()) {
                    AuthMenu temp = authMenus.get(i);
                    authMenus.set(i, authMenus.get(j));
                    authMenus.set(j, temp);
                }
            }
        }
        this.authMenus = authMenus;
    }
}



